﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain.MainModule.Entities;
using Infraestructure.Data.MainModule.UnitOfWork;
using Infraestructure.CrossCutting.Logging;
using Domain.MainModule.Rates;
using Infraestructure.Data.MainModule.Repositories;

namespace Infraestructure.Data.MainModule.Tests.RepositoriesTests
{
    /// <summary>
    ///This is a test class for RateRepositoryTest and is intended
    ///to contain all RateRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class RateRepositoryTest : RepositoryTestsBase<Rate>
    {
       public override System.Linq.Expressions.Expression<Func<Rate, bool>> FilterExpression
        {
            get { return a => a.RateId == TestConstants.Instance.RATE_ID; }
        }

        public override System.Linq.Expressions.Expression<Func<Rate, Guid>> OrderByExpression
        {
            get { return a => a.RateId; }
        }

        /// <summary>
        ///A test for FindRate
        ///</summary>
        [TestMethod()]
        public void FindRateById_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IRateRepository repository = new RateRepository(context, traceManager);

            RateIdSpecification spec = new RateIdSpecification(TestConstants.Instance.RATE_ID);

            //Act
            Rate rate = repository.FindRate(spec);

            //Assert
            Assert.IsNotNull(rate);
        }

        /// <summary>
        ///A test for FindRate
        ///</summary>
        [TestMethod()]
        public void FindRateByCountryId_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IRateRepository repository = new RateRepository(context, traceManager);

            RateCountryIdSpecification spec = new RateCountryIdSpecification(TestConstants.Instance.COUNTRY_ID);

            //Act
            IEnumerable<Rate> rate = repository.FindRates(spec);

            //Assert
            Assert.IsNotNull(rate);
        }
    }
}
